/*
 *
 *
Copyright (c) 1998-2001 Aristar, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. The end-user documentation included with the redistribution, if any,
must include the following acknowledgment:

"This product includes software developed by Aristar, Inc. (http://www.aristar.com/)."

Alternately, this acknowledgment may appear in the software itself, if and
wherever such third-party acknowledgments normally appear.

4. The names "Dialect" and "Aristar, Inc." must not be used to endorse or
promote products derived from this software without prior written permission.
For written permission, please contact info@aristar.com.

5. Products derived from this software may not be called "Dialect", nor may
"Dialect" appear in their name, without prior written permission of Aristar, Inc.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
ARISTAR, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This software consists of voluntary contributions made by many individuals
on behalf of Aristar, Inc.  For more information on Aristar, Inc.,
please see <http://www.aristar.com/>.

Portions of this software are based upon software freely available and
written by individuals not associated with Aristar, Inc.  Copyrights are
maintained in the relevant source code files.
 *
 *
 */

// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINFRM_H__56EEAB4A_C5EB_11D2_80D9_000000000000__INCLUDED_)
#define AFX_MAINFRM_H__56EEAB4A_C5EB_11D2_80D9_000000000000__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "DialectApp.h"

#ifdef IDE_SUPPORT

#include "DialectView.h"
//#include "ExpressionDlg.h"	// Added by ClassView
#include "DebugOutDlg.h"
#include "FindDlg.h"

extern VALUE g_ModNameToView;	// Frame {moduleName:(int)CDialectView*}
extern VALUE g_FilenameToView;	// Frame {filenameName:(int)CDialectView*}

#ifdef __MDI__
#	define BASEFRAMEWND CMDIFrameWnd
#else
#	define BASEFRAMEWND CFrameWnd
#endif

class CMainFrame : public BASEFRAMEWND
{
#ifdef __MDI__
	DECLARE_DYNAMIC(CMainFrame)
#else
	DECLARE_DYNCREATE(CMainFrame)
#endif

public:
	CMainFrame();

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMainFrame)
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
public:
	bool Find(CString text, bool bMatchCase);
	void ActivateDialectView(CDialectView* pView);
	void New();
	bool OpenFile(CString directory, CString filename);
	CDialectView* NewDialectView();
	CDialectView* IsBreakpoint(CString module, int line);
	void BreakpointLoop();
	static void BreakpointFunc(CString module, int line, CInterpreter* pInterp);
	void _BreakpointFunc(CString module, int line, CInterpreter* pInterp);
	virtual ~CMainFrame();
	CDebugOutDlg m_DebugOutDlg;
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
#ifndef __MDI__
	CDialectView* m_pCurrentDialectView;
	CObList m_DialectViewList;
#endif
	void UpdateWindowMenu();		// Keeps SDI Window menu current
	void OnWindowSelect(UINT id);	// Switch to window via menu (SDI only)

#ifndef UNDER_CE
	CStatusBar  m_wndStatusBar;
	CToolBar    m_wndToolBar;
#endif

// Generated message map functions
protected:
	void FlashLine(CString module, int line, COLORREF color);
	void DisplayError(VALUE vException);
	bool SaveAllButCurrentView();
	bool m_bRunning;
	CString m_InitialPath;
	//CExpressionDlg m_ExpressionDlg;
	CFindDlg m_FindDlg;

	CString m_MainModule;	// If !Empty, execute this on run
	bool m_bSaveAllOnRun;	// if true, auto save every file on run

	//
	// Step rules: (All might potentially need to load a module's text)
	//    SingleStep - Don't stop until call depth <= m_StepLevel
	//    StepInto - Call stack depth doesn't matter
	//    StepOut - Don't stop until call depth < m_StepLevel
	//    StepRun == Running normally
	//    StepPause == Sit in breakpoint loop until status changes
	//
	enum StepType {stepRun, stepPause, stepSingle, stepInto, stepOut};
	StepType m_Step;
	int m_StepLevel;	// Call stack depth at time of step command
	//bool m_bHalt;

	//{{AFX_MSG(CMainFrame)
	afx_msg void OnFileClose();
	afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnProjectRun();
	afx_msg void OnUpdateProjectRun(CCmdUI* pCmdUI);
	afx_msg void OnProjectSinglestep();
	afx_msg void OnUpdateProjectSinglestep(CCmdUI* pCmdUI);
	afx_msg void OnFileSave();
	afx_msg void OnFileOpen();
	afx_msg void OnFileNew();
	afx_msg void OnFileSaveAs();
	afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
	afx_msg void OnUpdateFileSaveAs(CCmdUI* pCmdUI);
	afx_msg void OnProjectContinue();
	afx_msg void OnUpdateProjectContinue(CCmdUI* pCmdUI);
	afx_msg void OnProjectPause();
	afx_msg void OnUpdateProjectPause(CCmdUI* pCmdUI);
	afx_msg void OnProjectAbort();
	afx_msg void OnViewLineNumbers();
	afx_msg void OnUpdateViewLineNumbers(CCmdUI* pCmdUI);
	afx_msg void OnClose();
	afx_msg void OnProjectStepinto();
	afx_msg void OnUpdateProjectStepinto(CCmdUI* pCmdUI);
	afx_msg void OnProjectStepout();
	afx_msg void OnUpdateProjectStepout(CCmdUI* pCmdUI);
	afx_msg void OnFilePrint();
	afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
	afx_msg void OnUpdateProjectAbort(CCmdUI* pCmdUI);
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnWindowNext();
	afx_msg void OnWindowPrevious();
	afx_msg void OnEditFind();
	afx_msg void OnUpdateEditFind(CCmdUI* pCmdUI);
	afx_msg void OnEditFindnext();
	afx_msg void OnUpdateEditFindnext(CCmdUI* pCmdUI);
	afx_msg void OnProjectAutosaveallonrun();
	afx_msg void OnUpdateProjectAutosaveallonrun(CCmdUI* pCmdUI);
	afx_msg void OnProjectCleardefaultmainmodule();
	afx_msg void OnUpdateProjectCleardefaultmainmodule(CCmdUI* pCmdUI);
	afx_msg void OnProjectSetdefaultmainmodule();
	afx_msg void OnUpdateProjectSetdefaultmainmodule(CCmdUI* pCmdUI);
	afx_msg void OnFileSaveall();
	afx_msg void OnProjectMakeexe();
	afx_msg void OnProjectInsertbreakpoint();
	afx_msg void OnEditCopy();
	afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
	afx_msg void OnEditCut();
	afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
	afx_msg void OnEditDelete();
	afx_msg void OnUpdateEditDelete(CCmdUI* pCmdUI);
	afx_msg void OnEditPaste();
	afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
	afx_msg void OnEditRedo();
	afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
	afx_msg void OnEditSelectall();
	afx_msg void OnEditUndo();
	afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
	afx_msg void OnViewDebugout();
	afx_msg void OnUpdateViewDebugout(CCmdUI* pCmdUI);
	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
	afx_msg void OnEditCommentOut();
	afx_msg void OnUpdateEditCommentOut(CCmdUI* pCmdUI);
	afx_msg void OnEditUncomment();
	afx_msg void OnUpdateEditUncomment(CCmdUI* pCmdUI);
	afx_msg void OnEditIndent();
	afx_msg void OnUpdateEditIndent(CCmdUI* pCmdUI);
	afx_msg void OnEditUnindent();
	afx_msg void OnUpdateEditUnindent(CCmdUI* pCmdUI);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

#endif // IDE_SUPPORT


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__56EEAB4A_C5EB_11D2_80D9_000000000000__INCLUDED_)
